/*******************************************************************************
 * Level Master 2000
 * Copyright (C) 2010 Christian Herzog
 * For more information see http://code.google.com/p/levelmaster2000/
 *
 * This file is licensed under the terms of the MIT license, see
 * http://www.opensource.org/licenses/mit-license.php for further information.
 ******************************************************************************/

#ifndef LOGGER_H
#define LOGGER_H

#include <QString>
#include <QDockWidget>
#include <QTextEdit>

class Logger : public QObject
{
    Q_OBJECT

public:
    enum LOG_LEVEL
    {
        LL_INFO,
        LL_WARNING,
        LL_ERROR,
        LL_DEBUG
    };

private:
    struct LogData
    {
        LOG_LEVEL logLevel;
        QString message;
    };

public:
    static Logger* instance();
    static void destroyInstance();
    void init( QWidget *parent );
    QDockWidget* logWidget;

private:
    static Logger* theInstance;
   // Logger( QWidget *parent );
    ~Logger();
    QTextEdit*	log;

    QString logfilePath;
    QString commandfilePath;

    QList<LogData> messages;

    bool showInfo;
    bool showWarning;
    bool showError;
    bool showDebug;

    void updateLog();

public:
    //Adds a log message to the log view.
    void addLogMessage( LOG_LEVEL level, QString loggerName, QString message );

    void addLogMessage( QString level, QString loggerName, QString message );

private slots:
    void clearButtonClicked();
    void showInfoButtonClicked();
    void showWarningButtonClicked();
    void showErrorButtonClicked();
    void showDebugButtonClicked();

};

#endif // ENTITY_H
